﻿using BootstrapBlazor.Components;
using Magicodes.ExporterAndImporter.Core.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BBCore.Application.Interface
{
    /// <summary>
    /// Magicodes通用EXCEL导入导出服务接口
    /// </summary>
    public interface IExporterAndImporterService
    {
        /// <summary>
        ///  EXCEL导入模板生成
        /// </summary>
        /// <typeparam name="T">要下载的表名</typeparam>
        /// <returns>返回文件路径</returns>
        Task<string> TemplateDownloadAsync<T>() where T : class, new();
        /// <summary>
        /// EXCEL导入模板验证出错信息生成
        /// </summary>
        /// <typeparam name="T">表名</typeparam>
        /// <param name="dataRowErrorInfos">验证错误信息,ImportResult<T>.RowErrors</param>
        /// <returns>返回文件路径</returns>
        Task<string> TemplateErrorInfoAsync<T>(IList<DataRowErrorInfo> dataRowErrorInfos) where T : class, new();
        /// <summary>
        /// 模板文件和要上传的数据以文件流方式生成ImportResult<T>对象的数据
        /// </summary>
        /// <typeparam name="T">表名</typeparam>
        /// <param name="uploadFile">bootstrapblazor上传组件</param>
        /// <param name="stream">上传的文件流</param>
        /// <returns>ImportResult<表名>的各项信息,包括ICollection<T> Data,IList<DataRowErrorInfo> RowErrors,Exception等</returns>
        Task<ImportResult<T>> importResultAsync<T>(UploadFile uploadFile, MemoryStream stream) where T : class, new();

        /// <summary>
        /// Excel导入模板文件路径,指定这个路径\wwwroot\ExcelFiles\ExcelTemplate
        /// </summary>
        /// <typeparam name="T">要下载的表名</typeparam>
        /// <returns></returns>
        string ExcelTemplatePath<T>() where T : class, new();
        /// <summary>
        /// Excel导入模板验证出错文件路径,指定这个路径\wwwroot\ExcelFiles\ExcelTemplateErrorInfo
        /// </summary>
        /// <typeparam name="T">要下载的表名</typeparam>
        /// <returns></returns>
        string ExcelTemplateErrorPath<T>() where T : class, new();
        /// <summary>
        /// 指定想要的列的数据动态导出,指定这个路径\wwwroot\ExcelFiles\DynamicExcelTemp
        /// </summary>
        /// <typeparam name="T">表名</typeparam>
        /// <param name="dataList">表的列表数据</param>
        /// <param name="fields">自定义导出想要的字段,例如"FirstName,LastName",大小写敏感,要与模型的字段名相同</param>
        /// <returns>返回文件路径</returns>
        Task<string> DynamicExportExcelAsync<T>(List<T> dataList, string fields) where T : class, new();
        /// <summary>
        /// 导出对象的全部数据,指定这个路径\wwwroot\ExcelFiles\DynamicExcelTemp
        /// </summary>
        /// <typeparam name="T">表名</typeparam>
        /// <param name="Data">要导出的数据</param>
        /// <returns></returns>
        Task<string> ExportExcelAsync<T>(ICollection<T> Data) where T : class, new();
     
    }
}
